<form class="layui-form" action="{:url()}" method="post" id="editForm">
	{:FormExt::input('姓名', 'name', '', '请输入姓名', 'required', 'lay-verify="required"')}
    {:FormExt::input('人数', 'number', '', '请输入人数', 'required', 'lay-verify="required|number"')}
    {:FormExt::input('金鹏编号', 'jp_number', '', '金鹏员工编号', '')}
    {:FormExt::select('工厂名称', 'factory_id', '',$factoryKV,'','','lay-verify="required" lay-filter="factory-id"')}
    {:FormExt::select('部门名称', 'depart_id', '', arrayGet($departMap, $factoryId, []),'','','lay-verify="required"')}
    {:FormExt::select('组别名称', 'group_id', '', arrayGet($groupMap, $factoryId, []),'','','lay-verify="required"')}
    {:FormExt::checkbox('工种', 'worktype', [],$worktype ,'', 'lay-verify="required"')}
    {:FormExt::radio('状态', 'status', [],$status ,'', 'lay-verify="required"')}

    <div class="pop-bottom-bar">
    	<input type="hidden" class="field-id" name="id">
        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit" hisi-data="{pop: true, refresh: true}">提交保存</button>
        <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
    </div>
</form>

{include file="system@block/layui" /}
    
<script>
	var departMap = {:json_encode($departMap)};
	var groupMap = {:json_encode($groupMap)};
    var formData = {:json_encode($formData)};
    layui.use(['form', 'func'], function() {
        var $ = layui.jquery, form = layui.form;
        layui.func.assign(formData);
        
        // 工厂下拉切换
        form.on('select(factory-id)', function(data){
        	var optionArr = departMap[data.value];
    		var option = '';
    		for(var i in optionArr) {
    			option += '<option value="'+i+'">'+optionArr[i]+'</option>';
    		}
    		$("select[name=depart_id] option").remove();
    		$('select[name=depart_id]').append(option);
    		
    		var optionGroupArr = groupMap[data.value];
    		var optionGroup = '';
    		for(var i in optionGroupArr) {
    			optionGroup += '<option value="'+i+'">'+optionGroupArr[i]+'</option>';
    		}
    		$("select[name=group_id] option").remove();
    		$('select[name=group_id]').append(optionGroup);
    		
    		form.render();
        }); 
    });
</script>